<?php  if (!defined('BASEPATH')) exit('No direct script access allowed'); 
/**
 * AWS Seimple Email Service

 * @category  CodeIgniter
 * @package   helpers
 * @author    Phyu
 * @version   0.1
*/
require_once APPPATH . '/libraries/ses.php';

if (! function_exists('send_email_via_ses'))
{
	function send_email_via_ses($to, $from, $subject, $htmlurl = NULL, $messagebody = NULL){
            $ses = new SimpleEmailService('AKIAJEI2PXZPM3HSAIDQ', '3EV+2sMuHdT+0C+iBGFyZCoxH2pw+ZLZ5Di/yWWZ');
           
            //print_r($ses->verifyEmailAddress('registration@gWorldTraveler.com'));
            //print_r($ses->verifyEmailAddress('admin@gWorldTraveler.com'));
            //print_r($ses->listVerifiedEmailAddresses());
            //$ses->deleteVerifiedEmailAddress('ronanchen2002@gmail.com');
            
            $m = new SimpleEmailServiceMessage();
            $m->addTo($to);
            $m->setFrom('gWorldTraveler.com<'.$from . '>');
            $m->setSubject($subject);
            //$m->addReplyTo('andy@example.com');
            //$m->addReplyTo(array('stanley@example.com', 'erin@example.com'));
            //$m->setMessageFromString($message);
            
            $m->setMessageFromString($messagebody, $htmlurl);
            $ses->sendEmail($m);
        }
      function send_email_via_aws($messageParam){
            $ses = new SimpleEmailService('AKIAJEI2PXZPM3HSAIDQ', '3EV+2sMuHdT+0C+iBGFyZCoxH2pw+ZLZ5Di/yWWZ');
            $m = new SimpleEmailServiceMessage();
            $m->addTo($messageParam['to']);
            $m->setFrom($messageParam['url'].'<'.$messageParam['from'] . '>');
            $m->setSubject($messageParam['subject']);
            if (isset($messageParam['replyTo']))
                  $m->addReplyTo($messageParam['replyTo']);

            $m->setMessageFromString($messageParam['messagebody'], $messageParam['messagebody']);
            $ses->sendEmail($m);
      }
}

?>